/// Parse string to f64, handling empty strings and commas
pub fn parse_f64(s: &str) -> Option<f64> {
    let cleaned = s.trim().replace(",", "");
    if cleaned.is_empty() || cleaned == "-" {
        None
    } else {
        cleaned.parse::<f64>().ok()
    }
}

/// Parse string to i64, handling empty strings and commas
pub fn parse_i64(s: &str) -> Option<i64> {
    let cleaned = s.trim().replace(",", "");
    if cleaned.is_empty() || cleaned == "-" {
        None
    } else {
        cleaned.parse::<i64>().ok()
    }
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn test_parse_f64() {
        assert_eq!(parse_f64("123.45"), Some(123.45));
        assert_eq!(parse_f64("1,234.56"), Some(1234.56));
        assert_eq!(parse_f64(""), None);
        assert_eq!(parse_f64("-"), None);
        assert_eq!(parse_f64("  "), None);
    }

    #[test]
    fn test_parse_i64() {
        assert_eq!(parse_i64("123"), Some(123));
        assert_eq!(parse_i64("1,234"), Some(1234));
        assert_eq!(parse_i64(""), None);
        assert_eq!(parse_i64("-"), None);
    }
}
